//
//  SecondCellButton.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/22.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "SecondCellButton.h"

@implementation SecondCellButton

- (instancetype)init {
    self  = [super init];
    if (self) {
        
        _firstview = [[UIView alloc] initWithFrame:CGRectMake(0, 5,15,15)];
        _firstview.layer.borderWidth = 0.5;
        _firstview.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _firstview.layer.cornerRadius = CGRectGetHeight(_firstview.frame)/2;
        _firstview.layer.masksToBounds = YES;
        _firstview.backgroundColor = DEFAULT_COLOR;
        [self addSubview:_firstview];
        [_firstview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.mas_centerY);
            make.centerX.equalTo(self.mas_centerX).with.offset(-30);
            make.width.mas_equalTo(15);
            make.height.mas_equalTo(15);
        }];
        
        
        _firstlabel = [[UILabel alloc] init];
//        _firstlabel.text = @"余额支付";
        _firstlabel.font = [UIFont systemFontOfSize:13];
//        _firstlabel.backgroundColor = [UIColor orangeColor];
        _firstlabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_firstlabel];
        [_firstlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.mas_centerY);
            make.centerX.equalTo(self.mas_centerX).with.offset(20);
            if (iPhone5) {
                make.width.mas_equalTo(WIDTH/5);
            } else {
                make.width.mas_equalTo(WIDTH/5);
            }
            make.height.mas_equalTo(15);
        }];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = self.frame;
        
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
    return self;

}
- (void)buttonClick:(UIButton *)button {
    self.firstview.backgroundColor = [UIColor greenColor];
    
    if ([self.delegate respondsToSelector:@selector(SecondCellButtonClick:)]) {
        [self.delegate SecondCellButtonClick:button];
    }
}


@end
